<?php
include "config.php";
$querys = "truncate table sama";
$adds = mysql_query($querys);
$result = mysql_query("SELECT count(*) FROM `jalur`");
$row = mysql_fetch_row($result);
$jumlah = $row[0];

for ($i=1; $i <= $jumlah; $i++){
	for ($j=$i+1; $j <= $jumlah; $j++){
	//echo $i." dan ".$j."<br>";
	$awal = mysql_query("SELECT id, lat, lng FROM `jalur` where id = $i");
	$awal = mysql_fetch_row($awal);
	$id1 = $awal[0];
	$lat1 = $awal[1];
	$lng1 = $awal[2];

	$akhir = mysql_query("SELECT id, lat, lng FROM `jalur` where id = $j");
	$akhir = mysql_fetch_row($akhir);
	$id2 = $akhir[0];
	$lat2 = $akhir[1];
	$lng2 = $akhir[2];

	
		if ($lat1 === $lat2 && $lng1 === $lng2){
		echo $id1." dan ".$id2."<br>";
		$query = "INSERT INTO sama (id1, id2) VALUES ($id1, $id2)";
		$add = mysql_query($query);
		}
	}
}
  

?> 